home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
programm
/
prog_a2m
/
mpydsp56
/
multiply.s56
< prev
Wrap
Text File
|
1995-05-02
|
3KB
|
128 lines
;*****************************************************************
;* DSP 56001 microprocessor source code for a 48bit (2^24.2^-24)
;* real number multiplier.
;*
;* X memory contains the whole part of number. Y memory contains
;* the fractional part. X1 and Y1 are the whole number registers.
;* X0 and Y0 are the fractional number register.
;*
;* - Resolution of Numbers -
;* 24 bits for whole number part and 24 bits for the fractional part.
;*
;* - Memory use -
;* Sx = Whole and fractional number source.
;* R1 = Results of multiply.
;*
;* x:aw = s1 whole number
;* y:af = s1 fractional number
;* x:bw = s2 whole number
;* y:bf = s2 fractional number
;* x:cw = r1 whole number results
;* y:cf = r1 fractional number results
;*
;* Source values will no longer have a negative sign after program has
;* made it's calculations.
;*
;* - Register use -
;* X1, X0, Y1, Y0, A, and B are trashed, so save them.
;*
;* - Signed numbers -
;* If either whole number or the fractional part is signed negative
;* then the whole and fractional part number will be negative.
;* Example:
;* x:address = 2, y:address = -.123456 = -2.123456
;* x:address = -2, y:address = .123456 = -2.123456
;* x:address = 2, y:address = .123456 = 2.123456
;*
;* Created by Robert W. Stiles. Freeware! Users are free to modify the
;* code to your taste. However you must include your name and what part
;* of the source code that was modifed. In other words keep a history
;* record. Some modification are required if you wish to make this a
;* program sub-routine. It's currently written to run as a program.
;*
;* Created with Hisoft DSP Assembler Verion 1.0 17 April 1994
org p:$40
multiply_48bits
move #>0,x0
move x0,x:s1_nf ; Clear sign flags
move x0,x:s2_nf
move #1,b2 ; For setting negate flag.
_ck_s1_fraction
btst #23,y:af ; Verifiy sign of fraction
jcc _ck_s1_whole
move y:af,a0
neg a
move b2,x:s1_nf
move a0,y:af
_ck_s1_whole ; Verify sign of whole number.
btst #23,x:aw
jcc _ck_s2_fraction
move x:aw,a0 ; Get the value.
neg a ; Make positive.
move b2,x:s1_nf ; Set negate flag.
move a0,x:aw ; Save value.
_ck_s2_fraction
btst #23,y:bf
jcc _ck_s2_whole
move y:bf,a0
neg a
move b2,x:s2_nf
move a0,y:bf
_ck_s2_whole
btst #23,x:bw
jcc _do_calc
move x:bw,a0
neg a
move b2,x:s2_nf
move a0,x:bw
_do_calc
move l:aw,x ; Load value to be multiplied.
move l:bw,y ; Load value to be multiplied.
clr a ; Clear used registers.
clr b ; Clear used registers.
mpyr x0,y0,a ; Multiply the s1 s2 fractions.
move a1,a0 ; Place results in fraction register.
move #0,a1 ; Clear whole register.
mpy x1,y0,b ; Multiply s1 whole and s2 fraction.
mac y1,x0,b ; Multiply/Add s2 whole and s1 fraction.
addr a,b ; Add and correct results.
mpy x1,y1,a ; Multiply s1 whole and s2 whole.
asr a ; Correct results.
move a0,a1 ; Move results into whole register.
move #0,a0 ; Clear fraction register.
add a,b ; Sum the results.
move x:s1_nf,x0 ; Check to see what sign it will be.
move x:s2_nf,a
sub x0,a
jeq _no_sign
neg b ; Make a negative value.
_no_sign
move b,l:cw ; Save results r1.
alldone jmp alldone
;*****************************************************************
org x:$00
aw dc -2
bw dc 2
cw dc 0
s1_nf dc 0
s2_nf dc 0
org y:$00
af dc -.123456
bf dc .123456
cf dc 0
end